<template>
  <div class="MB2 integral-select">
    <CIntegralSelect
      :allData="allData"
      :integralData="integral"
      :resourceType="Number(resourceType)"
      @useIntegral="useIntegral">
    </CIntegralSelect>
  </div>
</template>

<script>
import { CIntegralSelect } from '@xiaoe/nvwa';

export default {
  props: {
    resourceType: {
      default: ''
    },
    valuateData: {
      type: Object,
      default: () => ({})
    },
    allData: {
      type: Array,
      default: []
    }
  },
  components: {
    CIntegralSelect,
    // CIntegralSelect: () => import(/* webpackChunkName: "CIntegralSelect" */ "@xiaoe/nvwa/lib/c-integral-select"),
  },
  data() {
    return {
      is_use_integral: 0, // 是否使用积分
    }
  },
  computed: {
    integral() {
      if (this.valuateData?.points_info?.is_show_point) {
        this.is_use_integral = this.valuateData?.points_info?.is_use_integral || 0;
        return {
        ...this.valuateData?.points_info,
        is_use_integral: this.is_use_integral
      }
      }
      return {};
    }
  },
  methods: {
    /**
     * 点击积分组件按钮的回调
     */
    useIntegral(val) {
      this.is_use_integral = val;
      this.$emit('change', val == 1);
    }
  }
}
</script>
<style lang="scss">
.van-popup.integral-tip-popup{
  left: 0 !important;
}
</style>
<style scoped lang="scss">
.integral-select {
  padding: 0 0.32rem;
  background-color: #fff;

  ::v-deep .left-text {
    line-height: 1rem;
  }
  img{
    vertical-align: inherit;
  }

}
</style>